$(function () {
    $('#editPassForm').validationEngine('attach', {
        validationEventTrigger : 'blur',
        promptPosition: 'inline',
        scroll: true,
        focusFirstField : true,
        onValidationComplete : function (form, valid) {
            if (valid){
                modifyUser();
            }
        }
    });
});

//关闭窗口
function closeForm() {
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    parent.layer.close(index);
}

//修改个人密码
function modifyUser() {
	$.ajax({
        url: "../user/modifySalesmanPwd.htm",
        cache: false,
        type: "post",
        dataType: "json",
        data: $("#editPassForm").serialize(),
        success: function (result) {
            if (result.status == 0) {
                layer.msg(result.message, {icon: 1});
                //睡眠1秒后跳转到重新登录页面
                setTimeout(function(){
                	location.href = '../user/logout.htm';
                	return;
                }, 1000);
            }else{
            	layer.msg(result.message, {icon: 2});
            }
        }
    });
}
